package com.thh.api;

import com.thh.service.DispatchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author thh
 * @Description
 * @Version 1.0
 **/
@RestController
@RequestMapping("/dispatch-api")
public class DispatchController {

    @Autowired
    private DispatchService dispatchService;


    //下单后，添加调度信息
    @GetMapping("/diapatch")
    public String lock(String orderId) throws  Exception{
        Thread.sleep(4000L); //模拟业务耗时，接口调用者会认为耗时，超时不代表不往下执行，
        // 但是订系统回返回异常
        // 运单系统还继续往下执行，
        dispatchService.dispatch(orderId); // 将订单号分配给外卖小哥
        return "ok";
    }

}
